package com.foreveross.taskservice.taskcache.domain.airfreight;

import org.springframework.stereotype.Component;

import com.foreveross.taskservice.common.model.AbstractAction;
import com.foreveross.taskservice.common.model.airfreight.AirFreightTaskModel;
import com.foreveross.taskservice.taskcache.TaskRollbackConvertorApplication;
/**
 * 航空业运价模型的兑换工具
 * @author Administrator
 *
 */
@Component
public class AirFreightRollbackConvertorApplicationImpl implements TaskRollbackConvertorApplication<AirFreightTaskModel> {

	@Override
	public void conver(AirFreightTaskModel rollTask, AirFreightTaskModel cacheTask)throws Exception {
		cacheTask.setStatus(rollTask.getStatus());
		cacheTask.setRemarks(rollTask.getRemarks());
		cacheTask.setEndTime(rollTask.getEndTime());
		cacheTask.setCrawlCount(rollTask.getCrawlCount());//抓取的航班数量
		cacheTask.setGrabTimes(rollTask.getGrabTimes());//本次抓取的次数，有可能节点对这个任务进行了多次尝试
		cacheTask.setThreadName(rollTask.getThreadName());
		cacheTask.setProxyIp(rollTask.getProxyIp());
		cacheTask.setByteLength(rollTask.getByteLength());
		cacheTask.setAttachHbaseKey(rollTask.getAttachHbaseKey());
		cacheTask.setSourceRowkey(rollTask.getSourceRowkey());
		cacheTask.setSourceDataSize(rollTask.getSourceDataSize());
		for(AbstractAction action:rollTask.getActions()){
			cacheTask.addAction(action);
		}
	}


	@Override
	public Class<AirFreightTaskModel> getTaskModelClass() {
		return AirFreightTaskModel.class;
	}
	
}
